import Base from './Base'
import ProductHoldingsPK from './ProductHoldingsPK'

class ProductHoldings extends Base {
  constructor ({
    id = '',
    unionId = new ProductHoldingsPK({}),
    // 交易总份额
    totalShare = '0',
    totalBuyShare = '0',
    totalDonateShare = '0',
    totalBonusShare = '0',
    // 交易总金额
    totalAmount = '0',
    totalBuyAmount = '0',
    totalDonateAmount = '0',
    totalRedemptionAmount = '0',
    totalRedemptionFee = '0',
    // 交易总盈亏
    totalProfit = '0',
    totalRedemptionProfit = '0',
    totalBonusProfit = '0',
    // 其他
    currentAmount = '0',
    priorityNetvalue = '0',
    priorityAmount = '0',
    inferiorAmount = '0',
    expectBonusProfit = '0',
    expectRedemptionPrincipal = '0',
    expectRedemptionProfit = '0',
    expectProfit = '0'
  }) {
    super({id})

    this.unionId = new ProductHoldingsPK(unionId)
    this.totalShare = totalShare
    this.totalBuyShare = totalBuyShare
    this.totalDonateShare = totalDonateShare
    this.totalBonusShare = totalBonusShare
    this.totalAmount = totalAmount
    this.totalBuyAmount = totalBuyAmount
    this.totalDonateAmount = totalDonateAmount
    this.totalRedemptionAmount = totalRedemptionAmount
    this.totalRedemptionFee = totalRedemptionFee
    this.totalProfit = totalProfit
    this.totalRedemptionProfit = totalRedemptionProfit
    this.totalBonusProfit = totalBonusProfit
    this.currentAmount = currentAmount
    this.priorityNetvalue = priorityNetvalue
    this.priorityAmount = priorityAmount
    this.inferiorAmount = inferiorAmount
    this.expectBonusProfit = expectBonusProfit
    this.expectRedemptionPrincipal = expectRedemptionPrincipal
    this.expectRedemptionProfit = expectRedemptionProfit
    this.expectProfit = expectProfit
  }

  static async findOne (params) {
    let res = await ProductHoldings.$http.get(`${ProductHoldings.$name}/get`, {params})
    return new this(res)
  }
}
// 静态属性
ProductHoldings.$name = '/product/holdings'
export default ProductHoldings
